//
//  PatientBabyInfoCell.m
//  Doctor
//
//  Created by 阳光 on 16/9/7.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "PatientBabyInfoCell.h"

@interface PatientBabyInfoCell ()

// 怀孕次数
@property(nonatomic,strong)UILabel *pregnantNumberLabel;

@property(nonatomic,strong)UIView *pregnantNumberLine;

// 活产数
@property(nonatomic,strong)UILabel *liveBirthLabel;

@property(nonatomic,strong)UIView *liveBirthLine;

// 流产次数
@property(nonatomic,strong)UILabel *abortionLabel;

@property(nonatomic,strong)UIView *abortionLine;

// 宫外孕
@property(nonatomic,strong)UILabel *exfetationLabel;

@property(nonatomic,strong)UIView *exfetationLine;


@end

@implementation PatientBabyInfoCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=WhiteColor;
        
        self.pregnantNumberLabel.font=Font_Number(16);
        self.pregnantNumberLine.hidden=NO;
        
        self.liveBirthLabel.font=Font_Number(16);
        self.liveBirthLine.hidden=NO;
        
        self.abortionLabel.font=Font_Number(16);
        self.abortionLine.hidden=NO;
        
        self.exfetationLabel.font=Font_Number(16);
        self.exfetationLine.hidden=NO;
        
    };
    return self;
}

// birthYearLabel
-(UILabel *)pregnantNumberLabel
{
    if (!_pregnantNumberLabel) {
        _pregnantNumberLabel=[self getLabelWithText:@"无" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_pregnantNumberLabel];
        
        UILabel *leftPregnantNumberLabel=[self getLabelWithText:NSLocalizedString(@"Pregnancy", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftPregnantNumberLabel];
        
        [leftPregnantNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.mas_equalTo(kmargin);
        }];
        
        [_pregnantNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _pregnantNumberLabel;
}

-(UIView *)pregnantNumberLine
{
    if (!_pregnantNumberLine) {
        _pregnantNumberLine=[UIView new];
        _pregnantNumberLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_pregnantNumberLine];
        [_pregnantNumberLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.pregnantNumberLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _pregnantNumberLine;
}

// liveBirthLabel
-(UILabel *)liveBirthLabel
{
    if (!_liveBirthLabel) {
        _liveBirthLabel=[self getLabelWithText:@"无" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_liveBirthLabel];
        
        UILabel *leftLiveBirthLabel=[self getLabelWithText:NSLocalizedString(@"Live birth", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftLiveBirthLabel];
        
        [leftLiveBirthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.pregnantNumberLine.mas_bottom).offset(kmargin);
        }];
        
        [_liveBirthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.pregnantNumberLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _liveBirthLabel;
}

-(UIView *)liveBirthLine
{
    if (!_liveBirthLine) {
        _liveBirthLine=[UIView new];
        _liveBirthLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_liveBirthLine];
        [_liveBirthLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.liveBirthLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _liveBirthLine;
}

// abortionLabel
-(UILabel *)abortionLabel
{
    if (!_abortionLabel) {
        _abortionLabel=[self getLabelWithText:@"无" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_abortionLabel];
        
        UILabel *leftAbortionLabel=[self getLabelWithText:NSLocalizedString(@"Miscarriage", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftAbortionLabel];
        
        [leftAbortionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.liveBirthLine.mas_bottom).offset(kmargin);
        }];
        
        [_abortionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.liveBirthLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _abortionLabel;
}

-(UIView *)abortionLine
{
    if (!_abortionLine) {
        _abortionLine=[UIView new];
        _abortionLine.backgroundColor=MAIN_BACK_COLOR;
        [self.contentView addSubview:_abortionLine];
        [_abortionLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.abortionLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(kmargin);
            make.right.mas_equalTo(-kmargin);
            make.height.mas_equalTo(1);
        }];
    }
    return _abortionLine;
}

// exfetationLabel
-(UILabel *)exfetationLabel
{
    if (!_exfetationLabel) {
        _exfetationLabel=[self getLabelWithText:@"无" font:Font_Number(16) textColor:Color333333 textAlignment:NSTextAlignmentRight lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_exfetationLabel];
        
        UILabel *leftExfetationLabel=[self getLabelWithText:NSLocalizedString(@"Ectopic pregnancy", nil) font:Font_Number(16) textColor:Color666666 textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:leftExfetationLabel];
        
        [leftExfetationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(kmargin);
            make.top.mas_equalTo(self.abortionLine.mas_bottom).offset(kmargin);
        }];
        
        [_exfetationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.abortionLine.mas_bottom).offset(kmargin);
            make.right.mas_equalTo(-kmargin);
        }];
    }
    return _exfetationLabel;
}

-(void)setPatientInfoDic:(NSDictionary *)patientInfoDic
{
    _patientInfoDic=patientInfoDic;
    
    _pregnantNumberLabel.text=patientInfoDic[@"pregnant_count"];
    
    _liveBirthLabel.text=patientInfoDic[@"stillbirth"];
    
    _abortionLabel.text=patientInfoDic[@"abortion_count"];
    
    _exfetationLabel.text=patientInfoDic[@"gongwaiyun"];
}

@end
